<?php

namespace App\Http\Middleware;

use App\Http\Model\ShopAccount;
use App\Http\Model\WxFormIdData;
use Carbon\Carbon;
use Closure;
use Log;

class FormIdData
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        Log::info($request->all());
        if($request->has('formid') && $request->has('account_id') && $request->has('account_type') && $request->has('own_id')){
            WxFormIdData::create([
                'formid' => $request->formid,
                'account_id' => $request->account_id,
                'account_type' => $request->account_type,
                'own_id' => $request->own_id,
                'over_date'=> Carbon::now()->addDays(7)
            ]);
        }
        return $next($request);
    }
}
